package com.oig.auth.api;


import com.oig.auth.api.factory.UserFallbackFactory;
import com.oig.common.module.SysRequest;
import com.oig.sys.auth.dto.UserDto;
import com.oig.sys.auth.vo.UserVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@FeignClient(contextId = "userService", value = "sys-auth-server",path = "/user", fallbackFactory = UserFallbackFactory.class)
public interface UserService {

    /**
     * 根据用户名获取用户基本信息
     */
    @PostMapping(value = "/loadUser/{username}")
    UserVo loadUserByUsername(@PathVariable("username") String username);


    /**
     * 登录成功更新用户登录成功记录
     */
    @PostMapping(value = "/updateLoginSuccess")
    void updateLoginSuccess(@RequestBody UserDto userDto);

    /**
     * 登录失败更新用户登录失败记录
     */
    @PostMapping(value = "/updateLoginFail")
    void updateLoginFail(@RequestBody UserDto userDto);

    /**
     * 获取用户基本信息
     */
    @PostMapping(value = "/getUserById/{userId}")
    UserVo getUserById(@PathVariable("userId") Integer userId);

    @PostMapping(value = "/getUserByCode/{code}")
    UserVo getUserByCode(@PathVariable("code") String code);
    /**
     * 获取用户基本信息
     */
    @PostMapping(value = "/getUserByOldId/{oldId}")
    UserVo getUserByOldId(@PathVariable("oldId") String oldId);

    /**
     * 获取用户信息，包含部门，岗位，角色等
     */
    @PostMapping(value = "/info/{userId}")
    UserVo info(@PathVariable("userId") Integer userId);

    /**
     * 根据条件查询所有的用户
     */
    @PostMapping(value = "/listAllUser")
    List<UserVo> listAllUser(@RequestBody SysRequest<UserDto> userRequest);

    /**
     * 查询租户生效用户
     */
    @PostMapping(value = "/listAllTenUser/{tenantId}")
    List<UserVo> listAllTenUser(@PathVariable("tenantId") Integer tenantId);

    /**
     * 查询部门生效用户
     */
    @PostMapping(value = "/listAllDeptUser/{deptId}")
    List<UserVo> listAllDeptUser(@PathVariable("deptId") Integer deptId);

    @PostMapping(value = "/loadUsersByUserIds")
    List<UserVo> loadUsersByUserIds(@RequestBody List<Integer> userIdList);


    //@Operation(summary = "根据工号查询用户,仅仅返回用户基本资料")
    @PostMapping(value = "/loadUsersByUserCodes")
    List<UserVo> loadUsersByUserCodes(@RequestBody List<String> userCodeList);

}
